﻿using HBKY.Shop.Common.Exceptions;
using ZQCY.Watchmen.Common.Exceptions;

namespace HBKY.Shop.Common.Helper
{
    public class BusinessExceptionHelper
    {
        /// <summary>
        /// 直接抛出异常
        /// </summary>
        public static void Throw(string message)
        {
            throw new BusinessException(message);
        }

        /// <summary>
        /// 条件为假的时候抛出异常
        /// </summary>
        /// <param name="conditions"></param>
        /// <param name="message"></param>
        public static void ThrowIfFalse(bool conditions, string message)
        {
            if (!conditions)
                throw new BusinessException(message);
        }

        /// <summary>
        /// 条件为真的时候抛出异常
        /// </summary>
        /// <param name="conditions"></param>
        /// <param name="message"></param>
        public static void ThrowIfTrue(bool conditions, string message)
        {
            if (conditions)
                throw new BusinessException(message);
        }

        /// <summary>
        /// message不为空的时候提示
        /// </summary>
        /// <param name="message"></param>
        public static void ThrowIfMessageNotNull(string message)
        {
            if (!string.IsNullOrWhiteSpace(message))
                throw new BusinessException(message);
        }
    }
}